package day1_array.leetcode;

/**
 * 盛水最多的容器
 * 对撞指针
 * @Author: yuisama
 * @Date: 2022/3/30 18:02
 * @Description:
 */
public class Num11_MaxArea {
    public int maxArea(int[] height) {
        int max = 0;
        int l = 0;
        int r = height.length - 1;
        while (l < r) {
            int leftHeight = height[l];
            int rightHeight = height[r];
            max = Math.max(max,(r - l) * Math.min(leftHeight,rightHeight));
            if (leftHeight <= rightHeight) {
                l ++;
            }else {
                r --;
            }
        }
        return max;
    }
}
